package hanjia;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2025/2/10-上午11:29
 * Since  :   1.0
 * Version:   1.0
 */
public class LeetCode977 {

    public int[] sortedSquares(int[] nums) {
        int index=nums.length-1;
        int left=0;
        int right=nums.length-1;
        int[] result = new int[nums.length];
        while (left<=right){
            if (nums[left]*nums[left]>nums[right]*nums[right]){
                result[index--]=nums[left]*nums[left];
                left++;
            }else {
                result[index--]=nums[right]*nums[right];
                right--;
            }

        }
        return result;

    }
}
